﻿package racingGame.engine 
{
	import flash.display.Bitmap;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Vector3D;
	
	import away3d.cameras.Camera3D;
	import away3d.containers.View3D;
	import away3d.materials.BitmapMaterial;
	import away3d.primitives.Sphere;
	
	import collada.DAE;
	import racingGame.events.ScreenEvent;
	import racingGame.assets.Textures;
	import racingGame.assets.Meshes;
	
	
	/**
	 * ...
	 * @author Anibal G. Hormeche
	 */
	public class CarTestEngine
	{
		private var _view		:View3D;
		private var _camera		:Camera3D;
		private var _cat 		:DAE;
		
		
		public function CarTestEngine(view :View3D) 
		{
			_view = view;
			initializeWorld();
			initializeCamera();
		}
		
		
		public function update() :void 
		{
			if (_cat.mesh) {
			
				_cat.mesh.rotationX += 2;
				_cat.mesh.rotationY += 4;
				_cat.mesh.rotationZ += 6;
			}
		}
		
		
		private function initializeWorld() :void
		{
			_cat = new DAE();
			_cat.parse(Meshes.CAT, new BitmapMaterial(Textures.CAT));
			_cat.mesh.scale(5);
			_view.scene.addChild(_cat.mesh);
            _view.camera.lookAt(_cat.mesh.position);
		}
		
		
		private function initializeCamera():void
		{
			_camera = _view.camera;
			_camera.lookAt(_cat.mesh.position);
		}
		
		
		
		
	}

}